// pages/about/about.js
Page({
  data: {
    logs:[],
    key:'',
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    const that = this;
    that.sk = options.sk;
    that.key = options.key;
    that.setData({
      key: that.key
    })
    wx.request({
      url: 'https://open.iotechn.com/m.api',
      method: 'post',
      data: {
        _gp: 'executor', _mt: 'getDeviceLogPage', secretKey: options.sk, key: that.key, pageNo: 1
      },
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: function (res) {
        var data = res.data;
        if (200 == data.code) {
          data.result.data.forEach((item,index) => {
            var d = new Date(item.gmtCreate);
            item.logTime = (d.getMonth() + 1) + '/' + d.getDate() + " " + d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds()
          })
          that.setData({
            logs: data.result.data
          })
        } else {
          wx.showToast({
            title: 'error:' + data.code,
          })
        }
      }
    })
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  }
})